package org.bbelovic.devel.exercises.number;

public class IntegerToBinary {

    public static String toBinaryStringIterative(int n) {
        final StringBuilder sb = new StringBuilder();
        while (n != 0) {
            sb.append(n%2);
            n /= 2;
        }
        sb.reverse();
        return sb.toString();
    }
    
    public static String toBinaryStringRecursive(int n) {
        if (n <= 0) return "";
        return toBinaryStringRecursive(n/2) + (n % 2);
    }
}
